package casts.preloader
{
   
   import casts.impls.IViewObject;
   
   import com.greensock.TweenMax;
   
   import flash.display.MovieClip;
   import flash.events.Event;
   import flash.text.TextField;
   
   import jp.progression.casts.CastMovieClip;

   /**
    * @author cjboy1984@gmail.com
    */
   public class PreloaderView extends CastMovieClip implements IViewObject
   {
      // fla
//      public var mcBg:MovieClip;
//      public var tfPerc:TextField;

      public function PreloaderView(initObject:Object = null)
      {
         super(initObject);
         
         id = 'preloader_main';
         group = 'preloader';

         stop();
         
         addEventListener(Event.ADDED_TO_STAGE, onAdd);
         addEventListener(Event.REMOVED_FROM_STAGE, onRemove);
      }
      
      // --------------------- LINE ---------------------
      
      public function removeIt(immediately:Boolean = true):void
      {
         if (immediately)
         {
            if (parent) 
            {
               parent.removeChild(this);
            }
         }
         else
         {
            if (!TweenMax.isTweening(this) && parent)
            {
               TweenMax.to(this, 0.4, { alpha:0, onComplete:parent.removeChild, onCompleteParams:[this] } );
            }
         }
      }
      
      public function set perc(v:String):void 
      {
//         tfPerc.text = v;
      }
      
      // --------------------- LINE ---------------------
      
      public function onAdd(e:Event):void
      {
      }
      
      public function onRemove(e:Event):void
      {
      }
      
      public function onStageResize(e:Event):void
      {
      }

      // ################### protected ##################

      override protected function atCastAdded():void
      {
      }

      override protected function atCastRemoved():void
      {
      }

      // #################### private ###################
      
      // --------------------- LINE ---------------------
      
   }

}
